package com.yc.damai.biz;

import java.util.List;

import com.yc.damai.bean.User;
import com.yc.damai.dao.UserDao;

public class UserBiz {

	private UserDao dao = new UserDao();
	
	public User login(String username, String password) throws BizException {
		
		if(username==null || username.trim().isEmpty()) {
			throw new BizException("用户名不能为空");
		}
		
		if(password==null || password.trim().isEmpty()) {
			throw new BizException("密码不能为空");
		}
		
		List<User> list = dao.selectForLogin(username, password);
		
		if(list.isEmpty()) {
			throw new BizException("用户名或密码错误！");
		} else {
			return list.get(0);
		}
		
	}
	
}
